<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Axios案例</title>
    <script src="资料/vue.js"></script>
    <script src="资料/axios-0.18.0.js"></script>
</head>
<body>
    <div id="app">
        <table border="2px" cellspacing="0" width="80%">
            <tr>
                <th>编号</th>
                <th>姓名</th>
                <th>图像</th>
                <th>性别</th>
                <th>职位</th>
                <th>入职时间</th>
                <th>最后操作时间</th>
            </tr>
            <tr align="center" v-for="(teach,index) in teachs">
                <td>{{index+1}}</td>
                <td>{{teach.name}}</td>
                <td>
                    <img :src="teach.image" width="70px" height="50px">
                </td>
                <td>
                    <span v-if="teach.gender == 1">男</span>
                    <span v-else-if="teach.gender == 2">女</span>
                </td>
                <td>{{teach.job}}</td>
                <td>{{teach.entrydate}}</td>
                <td>{{teach.updatetime}}</td>
            </tr>
        </table>
    </div>
</body>
<script>
    //创建Vue对象，在视图上动态显示数据
    new Vue({
        el:"#app",
        data:{
            teachs:[]
        },
        //在钩子函数中获取数据
        mounted () {
            axios.get("https://mock.apifox.cn/m1/3128855-0-default/emp/list").then(result=>{
                this.teachs = result.data.data;
            })
        }
    });
</script>

</html>